package camid.services.nodemanager;

import camid.distribution.broker.Invoker;
import camid.distribution.protocol.MethodRequestMessage;
import camid.distribution.protocol.MethodResponseMessage;
import camid.infrastructure.Connector;
import camid.infrastructure.SenderQueue;

public class MockMigrationSenderQueue extends SenderQueue {

	private Invoker iv1;
	private int port1;
	
	private Invoker iv2;
	private int port2;
	
	public MockMigrationSenderQueue(Invoker iv1, int testPort1, Invoker iv2,
			int testPort2) {
		this.iv1 = iv1;
		this.port1 = testPort1;
		
		this.iv2 = iv2;
		this.port2 = testPort2;
	}

	public MethodResponseMessage doSend(Connector sender, MethodRequestMessage requestMessage)
	{
		MethodResponseMessage response = null;
		if(sender.getEndpoint().getPort().equals(port1))
		{
			response = this.iv1.invoke(requestMessage);
		}
		if(sender.getEndpoint().getPort().equals(port2))
		{
			response = this.iv2.invoke(requestMessage);
		}
		return response;	
	}
	
}
